package GIT;
import java.util.Scanner;
import static GIT.StudentInformation.students;

public class StatisticsGrade {
    public static void statisticsGrade(){
        System.out.println("输入课程名字");
        Scanner sc = new Scanner(System.in);
        String course = sc.nextLine();
        double sum = 0;
        double max = Double.MIN_VALUE;
        double min = Double.MAX_VALUE;
        int count = 0;

        for(Student student : students){
            if(student.getCourse().equals(course)){
                double grade = student.getGrade();
                sum += student.getGrade();
                max = Math.max(max, grade);
                min = Math.min(min, grade);
                count++;
            }
        }

        if(count == 0){
            System.out.println("未找到相关课程");
        }else{
            double average = sum / count;
            System.out.println("课程:" + course + ",平均分:" + average +",最高分" + max + ",最低分" + min);
        }
    }
}

